/*获取所需要的值*/
var songteacher_id = localStorage.songteacher_id;
var songteacher_phone = localStorage.songphone;
var songteacher_name = localStorage.songteacher_name;
var songteacher_subject = $("#subject").val();
var student_token = localStorage.phone;
var type = '';
if(songteacher_subject == 'one') {
	type = '送考科一';
} else if(songteacher_subject == "tow") {
	typt = '送考科二'
} else if(songteacher_subject == 'three') {
	type = '送考科三';
} else if(songteacher_subject == 'four') {
	type = '送考科四'
}

$(function() {
	$("#name").val(songteacher_name);
	$("#phone").val(songteacher_phone);

	$("#submit").click(function() {

		var songteacher_site = $("#site").val();
		var songteacher_time = $("#time").val();
		if(songteacher_site == '') {
			layer.msg("请填写正确地址");
			return false;
		}
		if(songteacher_time == '') {
			layer.msg('请填写正确时间')
			return false;
		}

		$.ajax({
			type: "post",
			url: "https://newapp.icandrive.cn/api/sendtest.php",
			dataType: "json",
			data: {
				teacher_id: songteacher_id,
				subject: songteacher_subject,
				address: songteacher_site,
				time: songteacher_time,
				phone: songteacher_phone,
				token: student_token,
			},
			success: function(data) {
				if(data.status == 200) {
					layer.msg('提交成功')
					    localStorage.type='送考';

			window.location.href="../alert_info/alert_esc.html"

				} else if(data.status == 250) {
					layer.msg("请重新登录");
					setInterval(function() {
						window.location.href = '../login/log_in.html'
					}, 3000)
				} else {
					layer.msg("预约失败")
				}
			},
			error: function() {
				layer.msg("系统繁忙")
			}

		});
	})

})

/*监听手机返回按键*/
return_keybord();
